// import { getCodeNum } from '@/utils/data.js'
import request from '@/utils/request'

// export const getCodeNumAPI = () => {
//   return getCodeNum()
// }

// 获取用户登录信息
export const getUserLoginApi = (params) => {
  console.log(params)
  const { username, password } = params
  return request({
    url: '/api/user/login',
    method: 'get',
    params: {
      username,
      password
    }
  })
}

// 注册用户信息
export const postUserRegisterApi = (params) => {
  // const { username, password } = params
  return request({
    url: '/api/user/register',
    method: 'post',
    data: params
  })
}

// 获取当前登录的用户信息
export const getUserInfoApi = (params) => {
  console.log(params)
  return request({
    url: '/api/user/find_user_info',
    method: 'get',
    params: params
  })
}

// 修改用户信息
export const putUserUpdateApi = (params, data) => {
  return request.put('/api/user/user_info', data, {
    params,
    headers: {
      'Content-Type': 'application/json' // 指定请求体为JSON格式
    }
  })
}

// 获取城市信息
export const getHotCityApi = (params) => {
  return request({
    url: '/api/hotcity/get_all_city',
    method: 'get',
    params: params
  })
}

// 根据城市编号删除城市信息
export const deleteCityApi = (params) => {
  return request({
    url: '/api/hotcity/delete_city_by_id',
    method: 'delete',
    params: params
  })
}

// 根据城市名称修改城市信息
export const putCityApi = (params, data) => {
  return request({
    url: '/api/hotcity/update_city',
    method: 'put',
    params: params,
    data: data
  })
}

// 获取城市区县信息
export const getAreaApi = (citycode) => {
  console.log('citycode', citycode)

  return request.get(`/api/area/get_area?cityCode=${citycode}`)
}

// 获取店铺信息
export const getShopApi = (query) => {
  const { city_id, area_id } = query
  return request.get(`/api/shop/get_shops?cityId=${city_id}&areaId=${area_id}`)
}
